package br.com.automed.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter(value="com.automed.marcaraRGConverter")
public class MascaraRGConverter implements Converter {

	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		
		if(value != null){
			value = value.replaceAll("[\\.-]", "");
		}
		
		return value;
	}

	public String getAsString(FacesContext context, UIComponent component, Object value) {
		
		return value != null ? value.toString() : null;
	}

}
